package LeetCode.tree;

public class LC_145 {
    public boolean checkSymmetricTree(TreeNode root) {
        if(root == null){
            return true;
        }
        return checkLeftAndRight(root.left,root.right);
    }
    public boolean checkLeftAndRight(TreeNode root1, TreeNode root2){
        if(root1 == null && root2 == null){
            return true;
        }
        if(root1 != null && root2 != null){
            if(root1.val == root2.val){
                boolean check1 = checkLeftAndRight(root1.left,root2.right);
                boolean check2 = checkLeftAndRight(root1.right,root2.left);
                return check1 && check2;
            }
        }
        return false;
    }
}
